define(() => {
    class EventEmitter {

        callbacksMap = {};

        emit(eventName, ...params) {
            if(!this.callbacksMap[eventName])
                return;
            this.callbacksMap[eventName].forEach(callback => callback(...params));
        }

        on(eventName, callback) {
            if(!this.callbacksMap[eventName])
                this.callbacksMap[eventName] = [];
            this.callbacksMap[eventName].push(callback);
        }

        once(eventName, callback) {
            if(!this.callbacksMap[eventName])
                this.callbacksMap[eventName] = [];
            const index = this.callbacksMap[eventName].length;
            this.callbacksMap[eventName][index] = (...params) => {
                callback(...params);
                this.callbacksMap[eventName].splice(index, 1);
            };
        }

    }

    return EventEmitter;
});